package core.convert;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.apache.poi.ss.formula.functions.T;
import utils.json.JsonUtil;

/**
 * @author : 翌擎科技
 * @date : 2022/7/25 16:31
 */
public class JsonConvert implements Converter<Object> {
    @Override
    public Class supportJavaTypeKey() {
        throw new UnsupportedOperationException("暂不支持，也不需要");
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        throw new UnsupportedOperationException("暂不支持，也不需要");
    }

    @Override
    public T convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        throw new UnsupportedOperationException("暂不支持，也不需要");
    }

    @Override
    public CellData convertToExcelData(Object object, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        // 生成 Excel 小表格
        return new CellData<>(JsonUtil.toJsonString(object));
    }
}
